package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.BaseContext;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/order")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    @PostMapping("/submit")
    private R<String> save(@RequestBody Orders orders){

//        Long currentId = BaseContext.getCurrentId();
        //创建分页构造器
ordersService.ordersAndorderDtail(orders);
        //创建查询构造器
//        LambdaQueryWrapper<Orders> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(Orders::getUserId,currentId);
        return R.success("添加成功");
    }



//    @GetMapping("/userPage")
//    private R<Page> page (int page, int pageSize){
//
//        Long currentId = BaseContext.getCurrentId();
//        //创建分页构造器
//        Page<Orders> page1 = new Page<>(page,pageSize);
//        //创建查询构造器
//        LambdaQueryWrapper<Orders> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(Orders::getUserId,currentId);
//        return R.success()
//    }
}
